<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
    <head>
        <title>职位管理</title>

        <link href="../../css/mine.css" type="text/css" rel="stylesheet" />
        <script type="text/javascript" src="/jquery/jquery-1.8.3.min.js"></script>
        <script type="text/javascript">
            /*全选方法*/
            $(function(){

                $("#buttonAll").click(function(){
                    /*得到点击按钮的状态*/
                    /*jq->js*/
                    var status=$(this)[0].checked;
                    //设置全选
                    var cks=document.getElementsByName("roleId");

                    for (var i = 0; i < cks.length; i++) {
                        console.log(cks[i])
                        cks[i].checked=status;
                    }
                })
            });

            /*删除指定角色*/
            function deleteUserRole(para) {
                alert("删除此角色?")
                $.ajax({
                    url:"/resource/demo3/deleRole",
                    data:{roleId:para},
                    type:"post",
                    dataType:"json",
                    success:function (re) {
                        alert(re.message)
                    }
                })
            }
            //批量删除角色
            function deleteAllRole() {
               var name = document.getElementsByName("roleId");
               if (name[0].checked==true){
                    document.forms[1].submit();
               }else {
                   alert("请选择要删除的对象!")
               }
            }
        </script>
        <style>
            .tr_color{background-color: #9F88FF}
            #del{
                color:orangered;
                cursor:pointer;
                text-decoration: underline;
            }
            #delAllRole{
                color:orangered;
                cursor:pointer;

            }
        </style>
    </head>
    <body>

        <div class="div_head">
            <span>
                <span style="float: left;">当前位置是：系统管理-》职位设置</span>
                <span style="float: right; margin-right: 8px; font-weight: bold;">
                    <a style="text-decoration: none;" href="/resource/demo3/preadd">【添加】</a>
					<span id="delAllRole"  onclick="deleteAllRole()">【删除】</span>
                </span>
            </span>
        </div>
        <div></div>
        <div class="div_search">
            <span>
                <form action="/resource/demo3/list" method="post">
                    职位名称:
					<input type="text"  name="roleName" value="${roleName}"/>
					 所属部门:
					<input type="text"  name="deptName" value="${deptName}"/>
					是否启用:
					<select name="status">
						<option value="${status}">---请选择---</option>
						<option value="1" >是</option>
						<option value="0">否</option>
					</select>
                    <input value="查询" type="submit" />

                </form>
            </span>
        </div>
        <div style="font-size: 13px; margin: 10px 5px;">

            <form id="delAll" action="/resource/demo3/deleteAllRole" method="post">
                <table class="table_a" border="1" width="100%">
                    <tbody>
                    <tr style="font-weight: bold;">
                        <td width="40px;">序号</td>
                        <td width="30px;"><input id="buttonAll" type="checkbox" /></td>
                        <td width="80px;"> 职位编码</td>
                        <td >职位名称</td>
                        <td width="100px;">职位分类</td>
                        <td width="120px;">所属部门</td>
                        <td width="120px;">状态</td>
                        <td align="center" width="100px;">操作</td>
                    </tr>
                    <c:forEach items="${pageInfo.list}" var="role" varStatus="sta">
                        <tr id="product1">
                            <td>${sta.count}</td>
                            <c:if test="${user.roleId==role.roleId}">
                                <td><input type="hidden" /></td>
                            </c:if>
                            <c:if test="${user.roleId!=role.roleId}">
                                <td><input name="roleId" type="checkbox" value="${role.roleId}"/></td>
                            </c:if>
                            <td>QMXC-${role.roleId}</td>
                            <td><a href="/resource/demo3/view?roleId=${role.roleId}">${role.roleName}</a></td>
                            <td>${role.classifyName}</td>
                            <td>${role.deptName}</td>
                            <c:if test="${role.status==1}">
                                <td>是</td>
                            </c:if>
                            <c:if test="${role.status!=1}">
                                <td>否</td>
                            </c:if>
                            <td>
                                <a href="">修改</a>
                                <c:if test="${user.roleId!=role.roleId}">
                                    <span id="del" onclick="deleteUserRole(${role.roleId})">删除</span>
                                </c:if>

                            </td>
                        </tr>
                    </c:forEach>


                    <tr>
                        <td colspan="20" style="text-align: center;">
                            <a style="text-decoration: none;" href="/resource/demo3/list?&classifyName=${classifyName}&status=${status}&deptName=${deptName}">首页</a>
                            <a style="text-decoration: none;" href="/resource/demo3/list?page=${pageInfo.prePage==0?1:pageInfo.prePage}&classifyName=${classifyName}&status=${status}&deptName=${deptName}"> 上一页  </a>
                            <a style="text-decoration: none;" href="/resource/demo3/list?page=${pageInfo.nextPage==0?pageInfo.pages:pageInfo.nextPage}&classifyName=${classifyName}&status=${status}&deptName=${deptName}">下一页  </a>
                            <a style="text-decoration: none;" href="/resource/demo3/list?page=${pageInfo.pages}&classifyName=${classifyName}&status=${status}&deptName=${deptName}"> 尾页 </a>
                            共${pageInfo.pages}页 每页显示 ${pageInfo.pageSize}/${pageInfo.total}
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>

        </div>

    </body>

</html>